{if condition="$instance['instancestatus'] neq 0"}
<style>
    .flowcontent input {
        pointer-events: none;
        border: 1px solid #DDD;
        background-color: #F5F5F5;
    }

    .flowcontent select {
        pointer-events: none;
        border: 1px solid #DDD;
        background-color: #F5F5F5;
    }

    .flowcontent textarea {
        pointer-events: none;
        border: 1px solid #DDD;
        background-color: #F5F5F5;
    }

</style>
{/if}
<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <input type="hidden" id="taskid" name="taskid" value="{$task->id ?? ''}" required autocomplete="off"
           class="layui-input" disabled>
    <input type="hidden" id="ids" name="ids" value="{$ids ?? ''}" required autocomplete="off"
           class="layui-input" disabled>
    <input type="hidden" id="flowcode" name="flowcode" value="{$flowCode ?? ''}" required autocomplete="off"
           class="layui-input" disabled>
    <input type="hidden" id="table" name="table" value="{$table ?? ''}" required autocomplete="off"
           class="layui-input" disabled>
    <input type="hidden" id="status" value="{$model.status ?? ''}" required autocomplete="off"
           class="layui-input" disabled>
    <div class="layui-row">
        <div id="dyhtml">
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">申请人</label>
                    <div class="layui-input-block">
                        <input type="text" value="{$originator.nickname ?? ''}" required placeholder="申请人"
                               autocomplete="off"
                               class="layui-input" disabled>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">申请部门</label>
                    <div class="layui-input-block">
                        <input type="text" value="{$model.group_name ?? ''}" required placeholder="申请部门"
                               autocomplete="off"
                               class="layui-input" disabled>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">申请时间</label>
                    <div class="layui-input-block">
                        <input type="text" value="  {$model.create_time ?? ''}" required placeholder="申请时间"
                               autocomplete="off"
                               class="layui-input" disabled>
                    </div>
                </div>
            </div>
            {if $model.typeName.name eq '用章'}
            {empty name="$model.zhang.yz_content"}
            <div class="layui-form-item ">
                <label class="layui-form-label">用章信息</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" isxsj='1'>{$model.content ?? ''}</textarea>
                </div>
            </div>
            {else /}
            <input type="hidden" name="yz_id" id="yz_id" value="{$model.zhang.id ?? ''}" required placeholder="用章ID"
                   autocomplete="off"
                   class="layui-input" disabled>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">申请类别</label>
                    <div class="layui-input-block">
                        <input type="text" value="{$model.typeName.name ?? ''}" required placeholder="申请类别"
                               autocomplete="off"
                               class="layui-input" disabled>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">用章类别</label>
                    <div class="layui-input-block">
                        <input type="text" id="yz_name" value="{$model.zhang.name ?? ''}" required placeholder="用章类别"
                               autocomplete="off"
                               class="layui-input" isxsj='1'>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md12">
                <div class="layui-form-item ">
                    <label class="layui-form-label">用章事由</label>
                    <div class="layui-input-block">
                        <textarea class="layui-textarea" id="yz_content"
                                  isxsj='1'>{$model.zhang.yz_content ?? ''}</textarea>
                    </div>
                </div>
            </div>
            {/empty}
            {elseif $model.typeName.name eq '借款'}
            {empty name="$model.money.jk_money"}
            <div class="layui-form-item ">
                <label class="layui-form-label">借款信息</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" disabled>{$model.content ?? ''}</textarea>
                </div>
            </div>
            {else /}
            <input type="hidden" name="jk_id" id="jk_id" value="{$model.money.id ?? ''}" required placeholder="借款ID"
                   autocomplete="off"
                   class="layui-input" disabled>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">借款金额</label>
                    <div class="layui-input-block">
                        <input type="text" name="jk_money" id="jk_money" value="{$model.money.jk_money ?? ''}" required
                               placeholder="借款金额"
                               autocomplete="off"
                               class="layui-input" isxsj='1'>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">金额(大写)</label>
                    <div class="layui-input-block">
                        <input type="text" value="{$model.money.dx ?? ''}" required placeholder="借款金额(大写)"
                               autocomplete="off"
                               class="layui-input" disabled>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">借款方式</label>
                    <div class="layui-input-block">
                        <input type="text" value="{$model.money.jk_fs ?? ''}" required placeholder="借款方式"
                               autocomplete="off"
                               class="layui-input" disabled>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">收款名称</label>
                    <div class="layui-input-block">
                        <input type="text" id="sk_name" value="{$model.money.sk_name ?? ''}" required placeholder="收款名称"
                               autocomplete="off"
                               class="layui-input" isxsj='1'>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">收款账号</label>
                    <div class="layui-input-block">
                        <input type="text" id="sk_zh" value="{$model.money.sk_zh ?? ''}" required placeholder="收款账号"
                               autocomplete="off"
                               class="layui-input" isxsj='1'>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">开户行</label>
                    <div class="layui-input-block">
                        <input type="text" id="sk_khh" value="{$model.money.sk_khh ?? ''}" required placeholder="开户行"
                               autocomplete="off"
                               class="layui-input" isxsj='1'>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
                <div class="layui-form-item ">
                    <label class="layui-form-label">借款用途</label>
                    <div class="layui-input-block">
                        <textarea class="layui-textarea" id="sk_content"
                                  isxsj='1'>{$model.money.sk_content ?? ''}</textarea>
                    </div>
                </div>
            </div>
            {/empty}

            {elseif $model.typeName.name eq '用车'}
            {empty name="$model.che"}
            <div class="layui-form-item ">
                <label class="layui-form-label">车辆信息</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" isxsj='1'>{$model.content ?? ''}</textarea>
                </div>
            </div>
            {else /}
            {if $model.status eq '-1'}
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
                <div class="layui-form-item">
                    <label class="layui-form-label"></label>
                    <div class="layui-input-block">
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th style="text-align: center;">起始地点</th>
                                <th style="text-align: center;">计划线路</th>
                                <th style="text-align: center;">开始时间</th>
                                <th style="text-align: center;">结束时间</th>
                                <th style="text-align: center;">用车天数</th>
                                <th style="text-align: center;">司机姓名</th>
                                <th style="text-align: center;">司机号码</th>
                                <th style="text-align: center;">用车人</th>
                                <th style="text-align: center;"></th>
                            </tr>
                            </thead>
                            <tbody id="che-index-table">
                            {foreach $model.che as $key=>$value}
                            <tr>
                                <td style="display: none;">
                                    <input type="hidden" name="yc_id[{$key}]" value="{$value.id ?? ''}" placeholder="用车ID"
                                           autocomplete="off"
                                           class="layui-input input num">
                                </td>
                                <td>
                                    <input type="text" name="start_address[{$key}]" value="{$value.start_address ?? ''}" placeholder="起始地点"
                                           autocomplete="off"
                                           class="layui-input input num">
                                </td>
                                <td style="text-align: center;">
                                    <input type="text" name="plan_lx[{$key}]" value="{$value.plan_lx ?? ''}" placeholder="计划线路"
                                           autocomplete="off"
                                           class="layui-input input num">
                                </td>
                                <td style="text-align: center;"><input type="number " name="start_time[{$key}]"  value="{$value.start_time ?? ''}" placeholder="开始时间"
                                                                       autocomplete="off"
                                                                       class="layui-input input num"></td>
                                <td>
                                    <input type="text" id="end_time[]" name="end_time[{$key}]"  value="{$value.end_time ?? ''}" placeholder="结束时间"
                                           autocomplete="off"
                                           class="layui-input input num">
                                </td>
                                <td style="text-align: center;">
                                    <input type="text" id="day[]" name="day[{$key}]"  value="{$value.day ?? ''}"  placeholder="用车天数"
                                           autocomplete="off"
                                           class="layui-input input num che_day">
                                </td>
                                <td style="text-align: center;">
                                    <input type="text" id="che_dj[]" name="che_dj[{$key}]"  value="{$value.che_dj ?? ''}"  placeholder="用车单价"
                                           autocomplete="off"
                                           class="layui-input input num che_dj">
                                </td>
                                <td style="text-align: center;">
                                    <input type="text" id="che_zongjia[]" name="che_zongjia[{$key}]"  value="{$value.day ?? ''}"  placeholder="用车总价"
                                           autocomplete="off"
                                           class="layui-input input num che_zongjia">
                                </td>
                                <td style="text-align: center;"><input type="text " id="sj_name[]" name="sj_name[{$key}]"  value="{$value.sj_name ?? ''}"  placeholder="司机姓名"
                                                                       autocomplete="off"
                                                                       class="layui-input input num"></td>
                                <td>
                                    <input type="text" id="sj_phone"  name="sj_phone[{$key}]" value="{$value.sj_phone ?? ''}"  placeholder="司机号码"
                                           autocomplete="off"
                                           class="layui-input input num">
                                </td>

                                <td style="text-align: center;"><input type="text" id="ycr" name="ycr[{$key}]" value="{$value.ycr ?? ''}" placeholder="用车人"
                                                                       autocomplete="off"
                                                                       class="layui-input input num"></td>
                                <td></td>
                            </tr>
                            {/foreach}
                            </tbody>
                        </table>

                    </div>
                </div>
            </div>
            {else /}
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
                <div class="layui-form-item ">
                    <label class="layui-form-label">车辆信息</label>
                    <div class="layui-input-block">
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th style="text-align: center;">起始地点</th>
                                <th style="text-align: center;">计划线路</th>
                                <th style="text-align: center;">开始时间</th>
                                <th style="text-align: center;">结束时间</th>
                                <th style="text-align: center;">用车天数</th>
                                <th style="text-align: center;">用车单价</th>
                                <th style="text-align: center;">用车总价</th>
                                <th style="text-align: center;">司机姓名</th>
                                <th style="text-align: center;">司机号码</th>
                                <th style="text-align: center;">用车人</th>

                            </tr>
                            </thead>
                            <tbody>
                            {foreach $model.che as $key=>$value}
                            <tr>
                                <td>
                                    {$value.start_address ?? ''}
                                </td>
                                <td style="text-align: center;">
                                    {$value.plan_lx ?? ''}
                                </td>
                                <td style="text-align: center;">{$value.start_time ?? ''}</td>
                                <td>
                                    {$value.end_time ?? ''}
                                </td>
                                <td style="text-align: center;">
                                    {$value.day ?? ''}
                                </td>
                                <td style="text-align: center;">
                                    {$value.che_dj ?? ''}
                                </td>
                                <td style="text-align: center;">
                                    {$value.che_zongjia ?? ''}
                                </td>
                                <td style="text-align: center;">{$value.sj_name ?? ''}</td>
                                <td>
                                    {$value.sj_phone ?? ''}
                                </td>

                                <td style="text-align: center;">{$value.ycr ?? ''}</td>
                            </tr>
                            {/foreach}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            {/if}

            {/empty}
            {elseif $model.typeName.name eq '采购'}
            {empty name="$model.caigou"}
            <div class="layui-form-item ">
                <label class="layui-form-label">采购信息</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" disabled>{$model.content ?? ''}</textarea>
                </div>
            </div>
            {else /}
            {if $model.status eq '-1'}
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
                <div class="layui-form-item ">
                    <label class="layui-form-label">采购信息</label>
                    <div class="layui-input-block">
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th style="text-align: center;">品名规格</th>
                                <th style="text-align: center;">数量</th>
                                <th style="text-align: center;">单价</th>
                                <th style="text-align: center;">总额</th>
                                <th style="text-align: center;">备注</th>

                            </tr>
                            </thead>
                            <tbody id="index-table">
                            {foreach $model.cg as $key=>$value}
                            <tr>
                                <input type="hidden" name="cg_id[{$key}]" value="{$value.id ?? ''}" placeholder="id"
                                       autocomplete="off"
                                       class="layui-input input num">
                                <td>
                                    <select name="cg_guige[{$key}]" lay-search=""  id="select">
                                        <option value="">直接选择或搜索选择</option>
                                        {foreach $cg_type as $key=>$vo}

                                        <option value="{$value.id}" {if condition="($value.cg_guige eq $vo.id)" }selected{/if}>{$vo.name}-{$vo.price}</option>
                                        {/foreach}
                                    </select>
                                </td>
                                <td style="text-align: center;">
                                    <input type="text" name="cg_num[{$key}]" value="{$value.cg_num ?? ''}" placeholder="请输入数量"
                                           autocomplete="off"
                                           class="layui-input input num cg_num">
                                </td>
                                <td style="text-align: center;">
                                    <input type="text" name="cg_dj[{$key}]" value="{$value.cg_dj ?? ''}" placeholder="请输入单价"
                                           autocomplete="off"
                                           class="layui-input input num cg_dj">
                                </td>
                                <td style="text-align: center;">
                                    <input type="text" name="cg_zongjia[{$key}]" value="{$value.cg_zongjia ?? ''}" placeholder="请输入总额"
                                           autocomplete="off"
                                           class="layui-input input num cg_zongjia">
                                </td>
                                <td style="text-align: center;"><input type="text" name="content[{$key}]" value="{$value.content ?? ''}"
                                                                       placeholder="请输入备注" autocomplete="off"
                                                                       class="layui-input"></td>
                            </tr>
                            {/foreach}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            {else /}
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
                <div class="layui-form-item ">
                    <label class="layui-form-label">采购信息</label>
                    <div class="layui-input-block">
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th style="text-align: center;">品名规格</th>
                                <th style="text-align: center;">数量</th>
                                <th style="text-align: center;">单价</th>
                                <th style="text-align: center;">总价</th>
                                <th style="text-align: center;">备注</th>

                            </tr>
                            </thead>
                            <tbody id="index-table">
                            {foreach $model.caigou as $key=>$value}
                            <tr>
                                <td>
                                    {$value.type.name ?? ''}-{$value.type.price ?? ''}
                                </td>
                                <td style="text-align: center;">
                                    {$value.cg_num ?? ''}
                                </td>
                                <td style="text-align: center;">
                                    {$value.cg_dj ?? ''}
                                </td>
                                <td style="text-align: center;">
                                    {$value.cg_zongjia ?? ''}
                                </td>
                                <td style="text-align: center;">{$value.content ?? ''}</td>
                            </tr>
                            {/foreach}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            {/if}
            {/empty}
            {/if}
            <!--            {if condition="$schme['flowcode'] eq 'journal' and $schme['flowname'] eq '日志'"}-->
            <!--            <div class="layui-form-item">-->
            <!--                <label class="layui-form-label">日志等级</label>-->
            <!--                <div class="layui-input-block">-->
            <!--                    <select name="journal_level_id" id="level_id" lay-search="">-->
            <!--                        <option value="">请选择日志类别</option>-->
            <!--                        {foreach $journal_level as $key=>$vo}-->
            <!--                        <option value="{$vo.id}">{$vo.name}</option>-->
            <!--                        {/foreach}-->
            <!--                    </select>-->
            <!--                </div>-->
            <!--            </div>-->
            <!--            {/if}-->
            {if condition="$instance['instancestatus'] neq 2"}
            <div class="layui-form-item">
                <label class="layui-form-label">审批意见</label>
                <div class="layui-input-block">
                    <textarea id="comment" class="layui-textarea" data-use-current="true" name="comment"></textarea>
                </div>
            </div>
            {/if}
            <div class="layui-form-item">
                <label class="layui-form-label">审批历史</label>
                <div class="layui-input-block">
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <td>审批人</td>
                            <td>审批步骤</td>
                            <td>审批意见</td>
                            <td>审批时间</td>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="history" id="vo" }
                        <tr>
                            <td>{$vo.nickname}</td>
                            <td>{$vo.stepname}</td>
                            <td>{$vo.comment}</td>
                            <td>{$vo.completedtime}</td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="form-group layer-footer">
                <label class="control-label col-xs-12 col-sm-2"></label>
                <div class="layui-input-block">
                    {if condition="$mode neq 'view'"}
                    {if condition="$instance['instancestatus'] eq 0"}
                    <button type="button" id='start' class="layui-btn">提交</button>
                    {elseif condition="$instance['instancestatus'] eq 1"/}
                    <button type="submit" id='agree' class="layui-btn btn-success btn-embossed disabled"
                            style="background-color: #18bc9c !important; border-radius: 5px;">同意
                    </button>
                    <button type="submit" id='refuse' class="layui-btn btn-danger btn-embossed disabled"
                            style="background-color: #e74c3c !important; border-radius: 5px;">拒绝
                    </button>
                    {else/}
                    {/if}
                    {/if}
                    <!--            {if condition="$instance['instancestatus'] neq 2 and $instance['instancestatus'] neq 3 and $instance['originator'] eq $auth->id"}-->
                    <!--                 <button type="submit" id='cancel' class="layui-btn btn-danger btn-embossed disabled"style="background-color: #e74c3c !important; border-radius: 5px;">取消</button>-->
                    <!--            {/if}-->
                    <button type="button" id='flowchart' class="layui-btn layui-btn-warm btn-embossed"
                            style="background-color: #f39c12 !important; border-radius: 5px;">流程图
                    </button>
                    {if $model.typeName.name eq '借款'}

                    <button type="button" id='dy' class="layui-btn layui-btn-warm btn-embossed"
                            style="background-color: #f39c12 !important; border-radius: 5px;">打印
                    </button>
                    {/if}
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/static/markdown/js/jquery.min.js"></script>
<script src="/static/markdown/lib/marked.min.js"></script>
<script src="/static/markdown/lib/prettify.min.js"></script>
<script src="/static/markdown/lib/raphael.min.js"></script>
<script src="/static/markdown/lib/underscore.min.js"></script>
<script src="/static/markdown/lib/sequence-diagram.min.js"></script>
<script src="/static/markdown/lib/flowchart.min.js"></script>
<script src="/static/markdown/lib/jquery.flowchart.min.js"></script>
<script src="/assets/libs/editormd/editormd.min.js"></script>
<script src="/static/admin/layui/layui.js"></script>
<script src="/static/admin/js/jquery.PrintArea.js"></script>
<script>
    var url = "{:url('Myworkitem/flowchart')}", edit = "{:url('Myworkitem/edit')}",
        refuse = "{:url('Myworkitem/refuse')}", check = "{:url('Myworkitem/check')}";
    layui.config({
        base: '/static/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
    }).use(['index', 'form', 'flow'], function () {
        var $ = layui.$, form = layui.form;
        var arr = []; //金额数组
        var cg_arr = []
        var taskid = $('#taskid').val();
        var ids = $('#ids').val();
        var flowcode = $('#flowcode').val();
        var table = $('#table').val();
        var param = $.param({'taskid': taskid, 'ids': ids, 'flowcode': flowcode});
        var status = $('#status').val();
        if (status != -1 || status != "-1") {
            $("[isxsj='1']").attr("disabled", true)
        }
        $('#agree').on('click', function (res) {
            var comment = $('#comment').val();
            $.ajax({
                url: edit,
                type: "post",
                data: {
                    'taskid': taskid,
                    'ids': ids,
                    'flowcode': flowcode,
                    'table': table,
                    'comment': comment,
                    'status': status
                },
                // beforeSend: function () {
                //     layer.load(2, {
                //         shade: [0.6, '#fff'], content: '数据提交中...', success: function (layero) {
                //             layero.find('.layui-layer-content').css({
                //                 'padding-top': '6px',
                //                 'width': '150px',
                //                 'padding-left': '40px'
                //             });
                //             layero.find('.layui-layer-ico16, .layui-layer-loading .layui-layer-loading2').css({
                //                 'width': '150px !important',
                //                 'background-position': '2px 0 !important'
                //             });
                //         }
                //     });
                // },
                success: function (res) {
                    if (res.code === 200) {
                        layer.msg(res.msg, {icon: 1});
                        var index = parent.layer.getFrameIndex(window.name); //获取当前窗口的name
                        parent.layer.closeAll();		//关闭窗口
                        window.parent.location.reload();
                    } else {
                        layer.msg(res.msg, {icon: 5});
                        return false;
                    }
                }
            });
        });
        $('#refuse').on('click', function (res) {
            var comment = $('#comment').val();
            $.ajax({
                url: refuse,
                type: "post",
                data: {
                    'taskid': taskid,
                    'ids': ids,
                    'flowcode': flowcode,
                    'table': table,
                    'comment': comment
                },
                beforeSend: function () {
                    layer.load(2, {
                        shade: [0.6, '#fff'], content: '数据提交中...', success: function (layero) {
                            layero.find('.layui-layer-content').css({
                                'padding-top': '6px',
                                'width': '150px',
                                'padding-left': '40px'
                            });
                            layero.find('.layui-layer-ico16, .layui-layer-loading .layui-layer-loading2').css({
                                'width': '150px !important',
                                'background-position': '2px 0 !important'
                            });
                        }
                    });
                },
                success: function (res) {
                    if (res.code === 200) {
                        layer.msg(res.msg, {icon: 1});
                        var index = parent.layer.getFrameIndex(window.name); //获取当前窗口的name
                        parent.layer.closeAll();		//关闭窗口
                        window.parent.location.reload();
                    } else {
                        layer.msg(res.msg, {icon: 5});
                        return false;
                    }
                }
            });
        });
        $('#flowchart').on('click', function (res) {
            layer.open({
                type: 2
                , title: "流程图"
                , content: url + '?' + param
                , area: ['70%', '70%']
                , maxmin: true
            });
        });
        $('#cancel').on('click', function (res) {
            console.log("取消");
        });
        $('#start').on('click', function (res) {
            var comment = $('#comment').val();
            var jk_money = $('#jk_money').val();
            var sk_name = $('#sk_name').val();
            var sk_zh = $('#sk_zh').val();
            var sk_khh = $('#sk_khh').val();
            var sk_content = $('#sk_content').val();
            var jk_id = $('#jk_id').val();
            //用章
            var yz_id = $('#yz_id').val();
            var yz_name = $('#yz_name').val();
            var yz_content = $('#yz_content').val();
            //用车
            var yc_id={};var start_address={};var plan_lx={};var start_time={};var end_time={};
            var day={};var sj_name={};var sj_phone={};var ycr={};
            $("input[name^='yc_id']").each(function (i, el) {
                yc_id[i] = $(this).val();
            });
            $("input[name^='start_address']").each(function (i, el) {
                start_address[i] = $(this).val();
            });
            $("input[name^='plan_lx']").each(function (i, el) {
                plan_lx[i] = $(this).val();
            });
            $("input[name^='start_time']").each(function (i, el) {
                start_time[i] = $(this).val();
            });
            $("input[name^='end_time']").each(function (i, el) {
                end_time[i] = $(this).val();
            });
            $("input[name^='day']").each(function (i, el) {
                day[i] = $(this).val();
            });
            $("input[name^='sj_name']").each(function (i, el) {
                sj_name[i] = $(this).val();
            });
            $("input[name^='sj_phone']").each(function (i, el) {
                sj_phone[i] = $(this).val();
            });
            $("input[name^='ycr']").each(function (i, el) {
                ycr[i] = $(this).val();
            });

            //采购
            var cg_id = {};
            var cg_guige = {};
            var cg_num = {};
            var cg_content = {};
            $("input[name^='cg_id']").each(function (i, el) {
                cg_id[i] = $(this).val();
            });
            $("select[name^='cg_guige']").each(function (i, el) {
                cg_guige[i] = $(this).val();
            });
            $("input[name^='cg_num']").each(function (i, el) {
                cg_num[i] = $(this).val();
            });
            $("input[name^='content']").each(function (i, el) {
                cg_content[i] = $(this).val();
            });
            $.ajax({
                url: edit,
                type: "post",
                data: {
                    'taskid': taskid,
                    'ids': ids,
                    'flowcode': flowcode,
                    'table': table,
                    'comment': comment,
                    'jk_money': jk_money,
                    'sk_name': sk_name,
                    'sk_zh': sk_zh,
                    'sk_khh': sk_khh,
                    'sk_content': sk_content,
                    'jk_id': jk_id,
                    'yz_id': yz_id,
                    'yz_name': yz_name,
                    'yz_content': yz_content,
                    'status': status,
                    yc_id,start_address,plan_lx,start_time,end_time,day,sj_name,sj_phone,ycr,cg_id,cg_guige,cg_num,cg_content
                },
                // beforeSend: function () {
                //     layer.load(2, {
                //         shade: [0.6, '#fff'], content: '数据新增中...', success: function (layero) {
                //             layero.find('.layui-layer-content').css({
                //                 'padding-top': '6px',
                //                 'width': '150px',
                //                 'padding-left': '40px'
                //             });
                //             layero.find('.layui-layer-ico16, .layui-layer-loading .layui-layer-loading2').css({
                //                 'width': '150px !important',
                //                 'background-position': '2px 0 !important'
                //             });
                //         }
                //     });
                // },
                success: function (res) {
                    if (res.code === 200) {
                        layer.msg(res.msg, {icon: 1});
                        var index = parent.layer.getFrameIndex(window.name); //获取当前窗口的name
                        parent.layer.closeAll();		//关闭窗口
                        window.parent.location.reload();
                    } else {
                        layer.msg(res.msg, {icon: 5});
                        return false;
                    }
                }
            });
        });
        $('#check').on('click', function (res) {
            layer.open({
                type: 2
                , title: "查看{$schme['flowname']}({$instance['instancecode']})"
                , content: check + '?' + param
                , area: ['100%', '100%']
                , maxmin: true
                // , btn: ['确定', '流程图', '取消']
                // , success: function (res) {
                //     console.log(data.instancestatus);
                // }
            });
        });
        $('#dy').on('click', function (res) {
            var mode = 'view';
            var url = '/admin/Finishworkitem/jkd?ids=' + ids + '&taskid=' + taskid + '&table=' + table + '&mode=' + mode +'&flowcode='+flowcode;
            var title = "借款单打印";
            top.layui.index.openTabsPage(url, title);  //完成页面跳转
            // $("#dyhtml").printArea();
            // return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        })

        //文本框焦点
        $('body').on('blur', '.input', function () {
            var value = $(this).val();
            if (value != null && value != '') {
                var num = $(this).parents("tr").find("input.che_day").val();
                var price = $(this).parents("tr").find("input.che_dj").val();
                var final = num * price;
                if (final != 0) {
                    arr.push(final);
                }

                $(this).parents("tr").find("input.che_zongjia").val(final);
                var total = eval(arr.join("+"));
                $('#total').text(total);
            }
        });

        //文本框焦点
        $('body').on('blur', '.input', function () {
            var value = $(this).val();
            if (value != null && value != '') {
                var num = $(this).parents("tr").find("input.cg_num").val();
                var price = $(this).parents("tr").find("input.cg_dj").val();
                var final = num * price;
                if (final != 0) {
                    cg_arr.push(final);
                }

                $(this).parents("tr").find("input.cg_zongjia").val(final);
                var total = eval(cg_arr.join("+"));
                $('#total').text(total);
            }
        });
    });
</script>
